import java.sql.*;
public class History {
    public static void main(String args[]) {
        Connection con=null;
        Statement sql;
        ResultSet rs;
        try{  Class.forName("com.mysql.jdbc.Driver");
        }
        catch(Exception e){}
        String uri = "jdbc:mysql://localhost:3306/world?useSSL=true&characterEncoding=utf-8";;
        String user ="root";
        String password ="";
        try{
            con = DriverManager.getConnection(uri,user,password);
        }
        catch(SQLException e){ }
        try {
            sql = con.createStatement();
            rs = sql.executeQuery("SELECT * FROM country where LifeExpectancy!=0 order by LifeExpectancy");
            rs.first();
            System.out.println("世界上的平均寿命最短的国家是:"+rs.getString(2)+
                    ",平均寿命为："+rs.getInt(8));
            rs.last();
            System.out.println("世界上的平均寿命最长的国家是:"+rs.getString(2)+
                    ",平均寿命为："+rs.getInt(8));
            con.close();
        }
        catch(SQLException e) {
            System.out.println(e);
        }
    }
}
